﻿using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NS
{
    [HotUpdate]
    [Description("新品规则表选择序号、颜色代码、物料分组更新新品SKU字段")]
    public class DataChangeSku : AbstractDynamicFormPlugIn
    {
        public override void DataChanged(DataChangedEventArgs e)
        {
            base.DataChanged(e);
            if (e.Field.Key.Equals("FNumber") || e.Field.Key.Equals("F_WNEG_Group") || e.Field.Key.Equals("F_WNEG_Base2"))
            {
                string FNumber = "", F_WNEG_Group = "", F_WNEG_Base2 = "";
                if (this.Model.GetValue("F_WNEG_Group") != null)
                {
                    FNumber = Convert.ToString(this.Model.GetValue("FNumber"));
                }
                    if (this.Model.GetValue("F_WNEG_Group") != null)
                {
                    F_WNEG_Group = Convert.ToString((this.Model.GetValue("F_WNEG_Group") as DynamicObject)["Number"]);
                }
                if (this.Model.GetValue("F_WNEG_Base2") != null)
                {
                    F_WNEG_Base2 = Convert.ToString((this.Model.GetValue("F_WNEG_Base2") as DynamicObject)["Number"]);
                }
                this.Model.SetValue("F_WNEG_Text1", F_WNEG_Group + FNumber + F_WNEG_Base2);
            }
           
        }
    }
    [Description("测试字段超链接标题点击事件"), HotUpdate]
    public class P20231022FieldLabelCickEdit : AbstractBillPlugIn
    {
        public override void FieldLabelClick(FieldLabelClickArgs e)
        {
            if (e.Key.EqualsIgnoreCase("FMaterialId"))
            {
                if(this.Model.GetValue("FMaterialId")==null)
                {
                    //取消后续响应逻辑。
                    e.Cancel = true;
                }
                else
                {
                    //取消后续响应逻辑。
                    e.Cancel = false;
                }
               

                //TODO：自己的二开逻辑。
                //xxx
            }
        }
    }
}
